#ifndef STOCKINFO_H
#define STOCKINFO_H

#include <QWidget>
#include <QLabel>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QUrl>
#include <QKeyEvent>

#include "stocksetting.h"


class StockInfo : public QWidget
{
    Q_OBJECT

public:
    explicit StockInfo(QWidget *parent = 0);
    ~StockInfo();

protected:
    void keyPressEvent(QKeyEvent *keyEvent);

private slots:
    void slotReplyFinished(QNetworkReply* reply);
    void slotUpdate();
    void slotPressedHotkey(int value);

private:
    void setTimer();
    void createDisplayLable();
    void addSelectedStock();
    inline QString KeepDecimal(double org, int digit);
    void removeInvalidCode(QStringList &stocksList);
    void parseStocksData(QStringList stocksList, QHash<int, QStringList>& hash);
    void setDisplayValue(QHash<int, QStringList>& hash);
    void setDisplayLabelSize(int width, int height);
    QBitmap createDisplayMask(int count);
    void setting();

private:
    QNetworkAccessManager* m_pNetworkManager;
    QUrl m_url;
    QString m_info;
    QLabel* m_pLabel;
    StockSetting *m_pStockSetting;
};

#endif // STOCKINFO_H
